#include <bits/stdc++.h>
using namespace std;


int N;
vector<int> A;

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N; A.assign(N, 0);
    for(auto & i : A) cin >> i;
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    cout << A[A.size() - 2] << endl;
    return 0;
}